package com.winsdom.entity.customer;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import javax.validation.Valid;
import javax.validation.constraints.*;
import java.io.Serializable;
import java.util.List;

/**
 * 个人客户基础信息实体
 * 存储个人客户的基本信息和证件信息
 */
@Data
@Schema(name = "CustomerPersonalBasicInfoRequest", description = "个人客户基础信息")
public class CustomerPersonalBasicInfoRequest implements Serializable {
    private static final long serialVersionUID = 1L;

    @Schema(description = "客户ID", example = "5", hidden = true)
    private Long customerId;

    @Schema(description = "客户类型", example = "3", required = true)
    @NotNull(message = "客户类型不能为空")
    @Min(value = 3, message = "客户类型无效")
    @Max(value = 3, message = "客户类型无效")
    private Integer customerType;

    @Schema(description = "客户姓名", example = "测试用户4", required = true)
    @NotBlank(message = "客户姓名不能为空")
    @Size(max = 50, message = "客户姓名长度不能超过50个字符")
    private String customerName;

    @Schema(description = "客户手机号", example = "19942355554", required = true)
    @NotBlank(message = "手机号不能为空")
    @Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
    private String mobilePhone;

    @Schema(description = "证件类型", example = "居民身份证", required = true)
    @NotBlank(message = "证件类型不能为空")
    @Size(max = 20, message = "证件类型长度不能超过20个字符")
    private String idType;

    @Schema(description = "证件号码", example = "110105119942355554", required = true)
    @NotBlank(message = "证件号码不能为空")
    @Size(max = 50, message = "证件号码长度不能超过50个字符")
    private String idNumber;

    @Schema(description = "电子邮箱", example = "ces4@example.com")
    @Email(message = "邮箱格式不正确")
    @Size(max = 100, message = "邮箱长度不能超过100个字符")
    private String email;

    @Schema(description = "证件照片地址", example = "/upload/idcard/4.jpg", required = true)
    @NotBlank(message = "证件照片地址不能为空")
    @Size(max = 255, message = "证件照片地址长度不能超过255个字符")
    private String idImagePath;

    @Schema(description = "联系人信息列表", example = "[{\"contactName\":\"王五\",\"contactMobile\":\"13567664888\",\"contactEmail\":\"wangwu@qq.com\",\"receiveProperties\":[\"海王星大厦\"]}]", required = true)
    @NotEmpty(message = "联系人信息不能为空")
    @Size(max = 3, message = "联系人数量不能超过3个")
    private List<@Valid ContactInfo> contactInfos;

    /**
     * 联系人信息子实体
     */
    @Data
    @Schema(name = "CustomerPersonalBasicInfoRequest.ContactInfo", description = "个人客户联系人信息")
    public static class ContactInfo {

        @Schema(description = "联系人姓名", example = "王五", required = true)
        @NotBlank(message = "联系人姓名不能为空")
        @Size(max = 50, message = "联系人姓名长度不能超过50个字符")
        private String contactName;

        @Schema(description = "联系人手机", example = "13567664888", required = true)
        @NotBlank(message = "联系人手机不能为空")
        @Pattern(regexp = "^1[3-9]\\d{9}$", message = "联系人手机格式不正确")
        private String contactMobile;

        @Schema(description = "联系人邮箱", example = "wangwu@qq.com")
        @Email(message = "联系人邮箱格式不正确")
        @Size(max = 100, message = "联系人邮箱长度不能超过100个字符")
        private String contactEmail;

        @Schema(description = "接收楼盘列表", example = "[\"海王星大厦\"]", required = true)
        @NotEmpty(message = "接收楼盘列表不能为空")
        private List<String> receiveProperties;
    }
}